package com.sunyard.iccs.util;

import java.util.Properties;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;


public class DecryptPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
	
	@Override
	protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException {
		String user = props.getProperty("username");
		String password = props.getProperty("password");
		DESEncrypt mycrypt = new DESEncrypt();
		String key = Constants.PWD_KEY;
		try {
			props.setProperty("username", mycrypt.getDecryptedString(key, user));
			props.setProperty("password", mycrypt.getDecryptedString(key, password));
		}
		catch (Exception e) {
			e.printStackTrace();
		}
		super.processProperties(beanFactoryToProcess, props);
	}
	
}
